{{> partials/menu}}
<main role="main" class="col-md-9 ml-sm-auto col-lg-10 px-4">
    <div class="col-sm-12">
        <h2>Products</h2>
    </div>
    <div class="col-sm-12 search_bar">
        <div class="input-group">
            <input type="text" name="product_filter" id="product_filter" class="form-control" placeholder="Filter products">
            <div class="input-group-append">
                <button class="btn btn-outline-success" id="btn_product_filter">Filter</button>
                <a href="/admin/products" class="hidden-xs btn btn-outline-warning">{{{feather 'x-octagon'}}}</a>
            </div>
        </div>
        <p class="text-warning top-pad-10">{{ @root.__ "Products can be filtered by: product title or product description keywords" }}</p>
    </div>
    <div class="col-sm-12">
        <ul class="list-group">
            <li class="list-group-item">
                <span class="float-right"><strong>{{ @root.__ "Published" }}</strong></span>
                {{#ifCond resultType '==' 'filtered'}}
                <strong>{{ @root.__ "Products" }} - <span class="text-danger">{{ @root.__ "Filtered term" }}: {{@root.searchTerm}} </span></strong>
                {{else}}
                <strong>{{ @root.__ "Recent products" }}</strong>
                {{/ifCond}}
            </li>
            {{#each results}}
                <li class="list-group-item">
                    <button class="float-right btn text-danger btn-delete-product" data-id="{{this._id}}"> {{{feather 'trash-2'}}}</button>
                    <h4 class="float-right"><input id="{{this._id}}" class="publishedState" type="checkbox" {{checkedState this.productPublished}}></h4>
                    <div class="top-pad-8"><a href="/admin/product/edit/{{this._id}}">{{this.productTitle}}</a></div>
                </li>
            {{/each}}
        </ul>
    </div>
    <div class="col-md-12 mt-5">
        <div id="pager" class="d-flex justify-content-center"></div>
    </div>
</div>
{{!-- Pager settings --}}
<input type="hidden" id="itemsPerPage" value="10" >
<input type="hidden" id="pageNum" value="{{pageNum}}">
<input type="hidden" id="totalItemCount" value="{{totalItemCount}}">
<input type="hidden" id="paginateUrl" value="{{paginateUrl}}">
<input type="hidden" id="searchTerm" value="{{searchTerm}}">
